Part Number Hot Search : 
FDS6680A 2SC39 LDGM3633 TCF70RN ADUM1 91139 A1121 61CNQ035
Product Description
Full Text Search
 

To Download AN1151 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN1151/0799 1/63 application note performance comparison between st72254 and pic16f876 by microcontroller division application team introduction stmicroelectronics has developed two sets of test routines related to 8-bit and low-end 16-bit microcontroller applications to evaluate the computing performance of microcontroller cores. these routines have been implemented on st72254 and pic16f876 microcontroller units. - the first set of routines has been written in assembler language to optimize their implementation and focus on core performance, without being dependent upon compiler code transformation. - the second set tries to evaluate the performance of the two mcus and their respective c compilers . this benchmark uses a c language program, representative of an automotive application. the c compilers used were from hiware on the st72 and from hi-tech on the pic16. the speed of the two mcus has been compared in two ways: - firstly, at the maximum frequency commercially available on each mcu. this means at an external frequency of 16mhz on the st72 and of 20mhz on the pic16. - secondly, at the same current consumption level (10ma). * this value is determined by interpolation as we can see, to reach the same consumption level on the two mcus, the pic's running fre- quency must be lowered to 10mhz (ext.) and the st72 can keep its maximum frequency of 16mhz (ext.). table 1: current consumption data (taken from datasheets) f ext f cpu consumption (max) st72254 16mhz 8mhz 10 ma run mode pic16c72a 20mhz 5mhz 20 ma run mode pic16c72a 10mhz * 2.5mhz 10 ma run mode 1a
2/63 performance comparison between st72254 and pic16f876 1 assembler test routines overview the set of test routines is made of 8 assembly programs which cover all the typical needs of an mcu application. this routine tests only the core performance and does not include any peripheral management. table 2. assembler test routine overview ? notes on memory accesses used in the test routines: the size of the arrays manipulated by the test routines has been chosen in order to minimize ram bank switching on the pic16 processor. this means that the results do not include any overhead for memory bank switching on the pic16 mcu. but with the complexity- levels of real-world applications, the paginated memory can be a major source of time and code overhead. for the same reason on the st72 the data are placed in the zero page, allowing to use the short addressing mode. abbreviated name full name description features stressed string string search search a 16-byte string in a 128- character array in rom 8-bit data block manipulation string manipulation char character search search a byte in a 40-byte array in rom 8-bit data manipulation char manipulation bubble bubble sort sort of a one-dimension array of 10 16-bit integers 16-bit data manipulation integer manipulation blkmov block move move a 64-byte block from a place in ram to another 8-bit data block manipulation block move convert block translation translate a 80-byte block in a different format 8-bit data manipulation use of a lookup table 16mul 16-bit integer multiplication multiplication of two unsigned words giving a 32-bit result 16-bit data computation integer manipulation shright 16-bit value right shift shift a 16-bit value five places to the right 16-bit data manipulation bit manipulation bitsrt bit manipulation set, reset, and test of 3 bits in a 128-bit array bit computation bit and 8-bit data manipulation 2
3/63 performance comparison between st72254 and pic16f876 2 assembler test results *the speed ratio is calculated as follows: (time pic16)/(time st72). so, a number higher than 1 means that the st72 is faster. - at their maximum frequency , we can see that the execution speed of the two mcus is truly comparable . even though, in this configuration the external frequency of the pic16 is higher (20mhz) than that of the st72 (16mhz). - at the same power consumption level, the st72254 is significantly better. in other words, for the same power consumption budget, the st72254 is nearly 2 times more powerful than the pic16f87x . table 3. execution speed at maximum frequency at a current of 10ma description pic16 @20mhz st72 @16mhz speed ratio st72/pic16* pic16 @10mhz st72 @16mhz speed ratio st72/pic16* string 371 m s282 m s 1.32 741 m s282 m s 2.63 search a 16-byte string in a 128-character array in rom char 84 m s57 m s 1.49 169 m s57 m s 2.98 search a byte in a 40-byte array in rom bubble 752 m s857 m s 0.88 1504 m s857 m s 1.76 sort of a one-dimensional array of 10 16-bit integers blkmov 154 m s121 m s 1.28 308 m s121 m s 2.55 move a 64-byte block from one place in ram to another convert 256 m s241 m s 1.06 513 m s241 m s 2.13 translate a 80-byte block into a different format shright 6 m s10 m s 0.65 13 m s10 m s 1.29 shift a 16-bit value five places to the right bitsrt 36 m s62 m s 0.58 72 m s62 m s 1.17 set, reset, and test of 3 bits in a 128-bit array 32div 124 m s222 m s 0.56 248 m s222 m s 1.12 unsigned division of a 32-bit dividend by a 16-bit divisor 16mul 41 m s18 m s 2.29 72 m s18 m s 4.58 multiplication of two unsigned words giving a 32-bit result avg. 203 m s 208 m s 0.98 406 m s 208 m s 1.95 average results
4/63 performance comparison between st72254 and pic16f876 2.1 results analysis ? bit manipulation: the microchip architecture is very fast for bit manipulation. modifying one bit in a data byte can be performed in only 1 cpu cycle which means in 0.2 m s@20mhz. to do the same operation the st72 needs 5 cpu cycles (0.625 m s@16mhz). ? memory access: the pic16 is faster in direct addressing mode (1 cycle 0.2 m s@20mhz compared to 3 cycles 0.375 m s@16mhz). this is very useful for many parts of the application where variables are di- rectly used, for example in loop control. the indirect mode of the pic16 (needed for table or string manipulation) is very slow, because its index register cannot be loaded without losing the content of the accumulator. the st72 with its two index registers and its wider choice of addressing modes allows very easy (and fast) data manipulation. to summarize, when there is no need for indirect addressing, the pic16 runs faster. but for more complex algorithms the st72 is better (faster and easier to program). moreover, the test routines use only a small amount memory so, there is no problem of bank switching. but in a real (and large-sized) application, this could be a major limitation of the pic16 architecture. ? use of constant tables the pic16 cannot read the content of its rom directly, this means that, constant tables must be handled in a strange way. it needs a sub-routine call and a computed jump. this takes at least 6 cpu cycles (1.2 m s@20mhz). on the st72, the same operation needs 6 cpu cycles (0.625 m s@16mhz). moreover, due to the need for a 8-bit computed jump, reading a constant table bigger than 256 bytes needs more time and code on the microchip architecture. ? multiplication: here, the comparison is easy: the st72 has a 8-bit multiply instruction. the pic16 does not have any. doing multiplication entirely by software implies considerable time and code over- head.
5/63 performance comparison between st72254 and pic16f876 3 c test routines overview the source program has been provided by a customer. it has 9 modules controlled by the main routine in `file7.c'. it uses all instructions usually found in c language programs. the source makes heavy use of unsigned char, bit and table manipulations. the modules are described in the following table. we have tried to highlight the main features of each module. note: number of lines: 1918. 3.1 modification of the source files the pic16 data memory is organised in banks which contains up to 96 bytes of ram. but, the hi-tech c compiler (pic16) does not distribute the variables automatically into these different banks. so, to make the compilation phase work, the sources files need to be modified . two files have been modified: `file2.c' and `file2.h'. the modifications consist of using the key- words bank1 and bank2 to place some of the variables in the different memory banks. for the st72 we have made two sets of sources. the first one called standard does not have any modifications . the second one called improved is modified to take more advan- tage of the use of the zero page. the only modified file is `file2.h' where two lines are added: #pragma data_seg short zeropage #pragma data_seg default table 4. module description module #lines description features stressed file1 204 after evaluation of a data by a switch, manipulation of aglobalo data and function calls (~100) switch/case processing function calls file2 538 definition of functions with data manipulation, for loop, while statement, if and switch uses loop statements arithmetic computation file3 93 definitions of 6 functions manipulating arrays, one function doing intensive calculation array manipulation bit calculation file4 251 mainly load of constant tables, and manipulation of structures at the end constant table manipulation structure use file5 164 exactly the same file than file8.c but using switch/case statement switch/case statement file6 68 if processing and bitwise computation bit manipulation and if use file7 133 the file contains the amaino, initialises data and calls functions in the other files function calls data initialisation file8 88 exactly the same file then file5.c if/else statements file9 34 signed char data computation signed data manipulation
6/63 performance comparison between st72254 and pic16f876 in order to make heavily-used global variables directly accessible (in short addressing mode) 4 c test results * these source files have been modified - in terms of execution speed, the results are the same as in the assembly routine test: the execution speed of the two mcus is truly comparable at their maximum frequency . and for the same power consumption budget, the st72 is nearly 2 times more powerful than the pic16. - in terms of program size: the reported size is between 20% and 30% higher on the st72 than on the pic16. but this is normal, because the memory of the pic16 is organised in words of 14 bits and not in bytes (8-bit) like on the st72. table 5. results st72 (standard) st72 (improved)* pic16* rom usage 7242 bytes 6849 bytes 5529 words of 14 bits ram usage 200 bytes 200 bytes 180 bytes execution time cpu cycle 96374 94312 62609 time at the maximum frequency 12.04ms@16mhz 11.78ms@16mhz 12.52ms@20mhz time at a 10ma current 12.04ms@16mhz 11.78ms@16mhz 25.04ms@10mhz
7/63 performance comparison between st72254 and pic16f876 5 compilation options 5.1 st72 hiware c compiler 5.1.1 compiler used: hicross+ compiler v5.0.3 hicross+ smartlinker v5.0.6 hiware tool v5.2.6 (all these programs come from the same package) 5.1.2 compilation options used (for all the sources files): -cc -cni -cu=i3 -lasm=%n.lst -ot -ou -obfv -oc description: -cc constant in rom -cni no integral promotion -cu=i3 loop unrolling 3 -lasm=%n.lst -ot optimize for time execution -ou optimize dead assignement -obfv optimize bitfield -oc do common expression elimination 5.1.3 project file (file.prm) link file.abs names file1.o+ file2.o+ file3.o+ file4.o+ file5.o+ file6.o+ file7.o+ file8.o+ file9.o+ start07.o ansi.lib end stacktop 0x017f sections rom = read_only 0xe000 to 0xffdf; ram = read_write 0x100 to 0x17f; zram = read_write 0x80 to 0xff; placement _zeropage,_overlap into zram; zeropage into zram; default_ram into zram,ram; default_rom into rom; rom_var into rom; end prestart off vector address 0xfffe _startup /* main */
8/63 performance comparison between st72254 and pic16f876 5.1.4 results of the compilation 5.1.4.1 standard sources ------------------------------------------------------ segmentname size type from to name rom_var 75d r f4ed fc49 rom funcs 14c1 r e02c f4ec rom copy 2 r e02a e02b rom startup 2a r e000 e029 rom =1c4a (dec: 7242) ------------------------------------------------------ segmentname size type from to name default_ram 90 r/w b8 fd zram 100 149 ram _overlap 18 r/w a0 b7 zram _zeropage 20 r/w 80 9f zram =c8 (dec: 200) rom size: 7242 ram size: 200 rexecution time: 96374 cpu cycles 12.04ms (@16mhz ext.) 5.1.5 improved sources this sources files a modified to take a better advantage of the use of the zeropage. ------------------------------------------------------ segmentname size type from to name rom_var 75d r f4ed fc49 rom funcs 1336 r e02c f361 rom copy 2 r e02a e02b rom startup 2a r e000 e029 rom =1abf (dec: 6847) ------------------------------------------------------ segmentname size type from to name default_ram 48 r/w 100 147 ram zeropage 48 r/w b8 ff zram _overlap 18 r/w a0 b7 zram _zeropage 20 r/w 80 9f zram =c8 (dec: 200) rom size: 6847 ram size: 200 execution time: 94312 cpu cycles 11.78ms (@16mhz ext.)
9/63 performance comparison between st72254 and pic16f876 5.2 pic16 hi-tech c compiler 5.2.1 compiler used hi-tech pic c compiler release 7.83pl1 5.2.2 compilation options used (for all the sources files) to make the compilation phase work, the sources files need to be modified . two files have been modified: `file2.c' and `file2.h'. the modifications consist of using the keywords bank1 and bank2 to place some of the variables in the different memory banks. compiler options: - processor pic16f876 - global optimization level 9 - peephole optimization enabled - assembler optimization enabled linker options: -ppowerup=0,intentry=4,intcode,intret,init ,end_init,clrtext,stringta- ble,strings -abank0=020h-07fh -prbss_0=bank0,rdata_0=bank0,idata_0=code -abank1=0a0h-0efh -prbss_1=bank1,rdata_1=bank1,idata_1=code -abank2=0110h-016fh -prbss_2=bank2,rdata_2=bank2,idata_2=code -abank3=0190h-01efh -prbss_3=bank3,rdata_3=bank3,idata_3=code -acombank=070h-07fh -ptemp=combank -acombank=070h-07fh -ptemp=combank -acode=0-7ffhx4 -aconst=0-0ffhx32 -pconfig=2007h -pidloc=2000h -pfloat_text0=code,float_text1=code,float_ text2=code -pfloat_text3=code,float_text4=code -pnvram=bank0,nvram_1=bank1,nvram_2=bank2, nvram_3=bank3 -q16f876
10/63 performance comparison between st72254 and pic16f876 5.2.3 results of the compilation program rom $0000 - $0fff $1000 (4096) words program rom $1000 - $109f $00a0 (0160) words program rom $1307 - $17ff $04f9 (1273) words $1599 (5529) words total program rom bank 0 ram $0020 - $0062 $0043 (67) bytes bank 0 ram $0070 - $007c $000d (13) bytes bank 1 ram $00a0 - $00ed $004e (78) bytes bank 3 ram $0190 - $01a5 $0016 (22) bytes $00b4 (180) bytes total ram rom size: 5529 words of 14 bits ram size: 180 bytes excution time: 62609 cpu cycles, 12.52ms@20mhz
11/63 performance comparison between st72254 and pic16f876 6 source code of the assembly routines you will find here, the source code of the main part of the test routine for each mcu. this will let you see that the routine has been optimized on the two processor, in order to reach a minimum execution time . the test routines also contain an initialisation part which is not taken into count for the speed measurement. 6.1 blkmov pic16 test: bsf portb,0 ;set i/o pin : beginning of measurement movlw bsize movwf i bsf status,irp ;choose bank 2 or 3 for indirect addressing mainlp: movlw addrs-1 addwf i,w movwf fsr movfw indf ;read one byte of the source movwf tmp movlw addrd-addrs ;set the address of the byte in the destination block addwf fsr,f movfw tmp movwf indf ;write one byte in the destination decfsz i,f goto mainlp bcf portb,0 ;reset i/o pin : end of measurement return 6.2 blkmov st72 .test bset pbdr, #0 ;set i/o pin : beginning of measurement ld x, #bsize .mainlp ld a, (addrs,x) ;read the source byte ld (addrd,x), a ;write it to the destination dec x jrne mainlp bres pbdr, #0 ;reset i/o pin : end of measurement ret
12/63 performance comparison between st72254 and pic16f876 6.3 string pic16 6.4 string st72 test: bsf portb,0 ;set i/o pin: beginning clrf x ;of measurement movlw 0 call table_string;read the first movwf strstart ;char of the string mainlp: ;find the first character movfw x call table_array incf x,f andlw 0xff ;compare w to zero bz bad subwf strstart,w ;compare current char bnz mainlp ;with the first of the movfw x ;string movwf x2 clrf y allcp: ;follow the comparison incf y,f ;after match with the movfw x2 ;first character call table_array andlw 0xff ;compare w to zero bz bad movwf tmp movfw y call table_string andlw 0xff ;compare w to zero bz fin subwf tmp,w ;comparison between the bnz mainlp ;two characters incf x2,f goto allcp bad: ;if string not found clrf x fin: ;result is available in x bcf portb,0 ;reset i/o pin: end of return ;measurement ;****************************************** table_array: addwf pcl,f array: dt axxxxxxxxpatterxxxxxxxxxxxxxxxxxxxxo dt axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo dt axxxxxxxxxxxxxpattern is here!xxxxxxo dt axxxxxxxxxxxxxxxxxxxxxxxxxo,0 table_string: addwf pcl,f string: dt opattern is here!o,0 .test bset pbdr, #0 ;set i/o pin : beginning ld x, #$ff ;of measurement .mainlp inc x ld a, (array,x) jreq bad ;check for the end cp a, string ;compare the current jrne mainlp ; char with the first push x ; of the string ld y, #1 .allcp ;follow the comparison inc x ; after match with the ld a, (array,x) ; first character jreq bad ;check for the end ld a, (string,y) jreq end ;end of the string ? cp a, (array,x) jrne save inc y jra allcp .bad ;if string not found clr x .end pop x ;result is available in x bres pbdr, #0 ;reset i/o pin: ret ;end of measurement .save pop x jra mainlp ;****************************************** .array dc.b axxxxxxxxpatterxxxxxxxxxxxxxxxxxxxxo dc.b axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo dc.b axxxxxxxxxxxxxpattern is here!xxxxxxo dc.b axxxxxxxxxxxxxxxxxxxxxxxxxo,0 .string dc.b apattern is here!o,0;searched string
13/63 performance comparison between st72254 and pic16f876 6.5 char pic16 test: bsf portb,0 ;set i/o pin : beginning of measurement movlw asize movwf idx ;set the index to end of the array call character movwf ch ;read the character mainlp: movfw idx call table_array ;read one character in the array subwf ch,w ;compare it with the searched one bz fin decfszidx,f ;do it until the beginning of the array as been reached goto mainlp fin: ;starting position in x if not found x=0 bcf portb,0 ;reset i/o pin : end of measurement return table_array: addwf pcl,f nop ;in order to let idx varies between max and 1 (faster) array: ;40 bytes array dt o--------o-------------------------------o character: dt oo o;searched char 6.6 char st72 .test bset pbdr, #0 ;set i/o pin : beginning of measurement ld x, #asize ;set x to point at the end of the array ld a, character ;store in a the searched character .mainlp cp a,({array-1},x);compare the current character to the searched one jreq end ;if character found, x contain the position dec x ;go to the previous character jrne mainlp .end ;if not found x=0 bres pbdr, #0 ;reset i/o pin : end of measurement ret .array ;40 bytes array dc.b o--------o-------------------------------o .character dc.b oo o;searched char
14/63 performance comparison between st72254 and pic16f876 6.7 bubble pic16 test: bsf portb,0;beginning of measurement bsf flag,0;flag=1 mainlp: movf flag,f bz fin clrf flag movlw num-1 movwf idx movlw array movwf x ;point on the first element movlw array+2 movwf y ;point on the second element intlp: movfw x movwf fsr movfw indf ;store in bufh the msb of the movwf bufh ; element pointed by x movfw y movwf fsr ;load in w the msb of the movfw indf ; element pointed by y subwf bufh,w;compare msbx and msby bz lsb ;if equal compare the lsb bnc noxch xch: ;at this point: msbx is in movfw indf ;bufh and fsr is set on msby movwf tmph ;store msby in tmph incf fsr,f ;point lsb y movfw indf movwf tmpl ;store lsby in tmpl movfw x movwf fsr movfw tmph ;put msby in the location of msbx movwf indf incf fsr,f ;point on lsbx movfw indf movwf bufl ;store lsbx in bufl movfw tmpl movwf indf ;put lsby in the location of lsbx movfw y movwf fsr ;point to msby movfw bufh movwf indf ;put msbx in the location of msby incf fsr,f ;point on lsby movfw bufl movwf indf ;put msby in the location of msbx bsf flag,0;set flag to continue sorting noxch: movlw 2 addwf x,f ;set x on the next element addwf y,f ;set x on the next element decfszidx,f goto intlp goto mainlp lsb: ;comparison of the lsb incf x,w movwf fsr ;point to lsbx movfw indf movwf bufl ;store lsbx in bufl incf y,w ;point to lsby movwf fsr movfw indf ;store lsby in w decf fsr,f ;fsr point on msby (for xch:) subwf bufl,w;compare lsbx and lsby bc xch ;exchange if needed goto noxch fin: bcf portb,0;end of measurement return
15/63 performance comparison between st72254 and pic16f876 6.8 bubble st72 .test bset pbdr, #0 ;beginning of measurement bset flag,#0 ;flag=1 .mainlp btjf flag,#0,end ;if flag=0 it is finish bres flag,#0 ld x, #0 ld y, #2 .intlp ld a, (array,x) cp a, (array,y) ;compare msbx and msby jreq lsb ;if equal compare the lsb jrult noxch .xch ;exchange two words ld a, (array,x) ld buf, a ;save msbx in buf ld a, (array,y) ;store msby in ld (array,x), a ; the location of msbx ld a, buf ;store msbx in ld (array,y), a ; the location of msby ld a, ({array+1},x) ld buf, a ;save lsbx in buf ld a, ({array+1},y) ;store lsby in ld ({array+1},x), a ; the location of lsbx ld a, buf ;store lsbx in ld ({array+1},y),a ; the location of lsby bset flag,#0 ;set flag to continue .noxch inc y inc y ;make x and y point inc x ; to the next integer inc x ; (16-bit) cp x, #{last - 2} ;check for end of array jrne intlp jra mainlp .lsb ;compare the two lsb ld a,({array+1},x) cp a,({array+1},y) ;compare lsby and lsby jrugt xch jra noxch .end bres pbdr, #0 ;end of measurement ret
16/63 performance comparison between st72254 and pic16f876 6.9 convert pic16 test: bsf portb,0 ;set i/o pin : beginning of measurement movlw bsize movwf i mainlp: movlw srcblock-1 addwf i,w movwf fsr movfw indf ;read the current value in the source block addlw table ;put in w the index in the lookup table movwf fsr movfw indf movwf tmp ;put in tmp the value in the new format movlw dstblock-1 addwf i,w movwf fsr ;point to the destination block movfw tmp movwf indf ;write the new value in the destination block decfsz i,f goto mainlp bcf portb,0 ;reset i/o pin : end of the measurement return 6.10 convert st72 .test bset pbdr, #0 ;set i/o pin : beginning of measurement ld x, #bsize ;set the index register to the end of the srcblock .mainlp ld a,({srcblock-1},x) ;load the current byte in the source block ld y, a ld a, (table,y) ;load the corresponding value from the lookup table ld ({dstblock-1},x), a ;store it in the destination block dec x ;go to previous byte jrne mainlp ;until the first is reached bres pbdr, #0 ;reset i/o pin : end of measurement ret
17/63 performance comparison between st72254 and pic16f876 6.11 shright pic16 test: bsf portb,0 ;set i/o pin : beginning of measurement movlw 00 movwf h ;set the high byte of the word movlw 0x40 movwf l ;set the low byte of the word movlw 5 movwf idx ;set the number of bit to rotate bcf status,c ;reset the carry mainlp: rrf h,f rrf l,f decfsz idx,f goto mainlp bcf portb,0 ;reset i/o pin : end of measurement return 6.12 shright st72 .test bset pbdr, #0 ;set i/o pin : beginning of measurement ld a, #5 ;set the number of bit to rotate ld x, #0 ;set the high byte of the word ld y, #$40 ;set the low byte of the word .mainlp rrc x rrc y dec a jrne mainlp bres pbdr, #0 ;reset i/o pin : end of measurement ret
18/63 performance comparison between st72254 and pic16f876 6.13 bitsrt pic16 test: bsf portb,0 ;beginning of measurement movlw .10 movwf idx ;bit10 -> bit 2, byte 1 call setbit call resetbit call testbit movlw .13 ;bit13 -> bit 5, byte 1 movwf idx call setbit call resetbit call testbit movlw .123 ;bit 123 -> bit 3, byte 15 movwf idx call setbit call resetbit call testbit bcf portb,0 ;end of measurement return setbit: movfw idx andlw b'111' movwf offset ;bit number bcf status,c rlf idx,w andlw h'f0' movwf fsr swapf fsr,f ;byte number movlw flags addwf fsr,f ;address of the byte. rlf offset,w ;do w=offset*2 (carry=0) addwf pcl,f ;jump into the following bsf indf,0 ; table return bsf indf,1 return bsf indf,2 return bsf indf,3 return bsf indf,4 return bsf indf,5 return bsf indf,6 return bsf indf,7 return resetbit: movfw idx andlw b'111' movwf offset rlf idx,w andlw h'f0' movwf fsr swapf fsr,f movlw flags addwf fsr,f bcf status,c rlf offset,w addwf pcl,f bcf indf,0 return bcf indf,1 return bcf indf,2 return bcf indf,3 return bcf indf,4 return bcf indf,5 return bcf indf,6 return bcf indf,7 return testbit: movfw idx andlw b'111' movwf offset rlf idx,w andlw h'f0' movwf fsr swapf fsr,f movlw flags addwf fsr,f bcf status,c swapf offset,f rrf offset,w addwf pcl,f btfsc indf,0 return bsf indf,0 bsf status,z return nop ;the 3 nops in the table nop ;allow a good speed nop ;optimization
19/63 performance comparison between st72254 and pic16f876 btfsc indf,1 return bsf indf,0 bsf status,z return nop nop nop btfsc indf,2 return bsf indf,0 bsf status,z return nop nop nop btfsc indf,3 return bsf indf,0 bsf status,z return nop nop nop btfsc indf,4 return bsf indf,0 bsf status,z return nop nop nop btfsc indf,5 return bsf indf,0 bsf status,z return nop nop nop btfsc indf,6 return bsf indf,0 bsf status,z return nop nop nop btfsc indf,7 return bsf indf,0 bsf status,z return nop nop nop
20/63 performance comparison between st72254 and pic16f876 6.14 bitsrt st72 .test bset pbdr, #0 ;beginning of measurement ld a, #10 ld idx,a call setbit call resetbit call testbit ld a, #13 ld idx,a call setbit call resetbit call testbit ld a, #123 ld idx,a call setbit call resetbit call testbit bres pbdr, #0 ;end of measurement ret .setbit ld a,idx sla a and a,#$f0 swap a ;number of the byte add a, #flags ;address of the byte ld x,a ld a,idx and a,#%111 ld y,a ;bit number ld a,(bittbl,y) or a,(x) ;set the bit in the array ld (x),a ret .resetbit ld a,idx sla a and a,#$f0 swap a ld x,a ld a,idx and a,#%111 ld y,a ld a,(bittblinv,y) and a,(x) ;reset bit in the array ld (x),a ret .testbit ld a,idx sla a and a,#$f0 swap a add a, #flags ld x,a ld a,idx and a,#%111 ld y,a ld a,(bittbl,y) ld y,a ;save the value and a,(x) ;test if the bit is reset jrne isone ld a,y or a,(x) ld (x),a ;set bit in the array and a,#0 ;set the zero flag .isone ret .bittbl dc.b $01,$02,$04,$08,$10,$20,$40,$80 .bittblinv dc.b $fe,$fd,$fb,$f7,$ef,$df,$bf,$7f
21/63 performance comparison between st72254 and pic16f876 6.15 32div pic16 6.16 32div st72 test: bsf portb,0 ;beginning of measurement movlw d'32' movwf cpt clrf reste clrf reste+1 bcf status,c execute: rlf dividend+3,f;shift left dividend rlf dividend+2,f rlf dividend+1,f rlf dividend,f rlf reste+1,f rlf reste,f ; test if reste is >= to the divisor bc dividendlsgreater ; reste is 17 bits movfw reste subwf divisor,w bnc dividendlsgreater bnz nosubstract movfw reste+1 subwf divisor+1,w bc nosubstract dividendlsgreater: ;substract divisor movfw divisor+1 ;from left dividend subwf reste+1,f btfss status,c decf reste,f movfw divisor subwf reste,f bsf status,c decfszcpt,f ; decrement loop counter goto execute ; if cpt = 0 then exit goto out nosubstract: bcf status,c decfszcpt,f ; decrement loop counter goto execute ; if cpt = 0 then exit out: rlf dividend+3,f rlf dividend+2,f rlf dividend+1,f rlf dividend,f bcf portb,0 ;end of measurement return .test bset pbdr, #0 ;beginning of measurement ld x,#32 clr {reste} clr {reste+1} rcf .execute rlc {dividend+3} ;shift left dividend rlc {dividend+2} rlc {dividend+1} rlc {dividend} rlc {reste+1} rlc {reste} ; test if reste is >= to the divisor jrc dividendlsgreater ; reste is 17 bits ld a,{divisor} cp a,{reste} jrugt nosubstract jrne dividendlsgreater ld a,{divisor+1} cp a,{reste+1} jrugt nosubstract .dividendlsgreater ; substract divisor ld a,{reste+1} sub a,{divisor+1} ld {reste+1},a ld a,{reste} sbc a,{divisor} ld {reste},a scf dec x ; decrement loop counter jrne execute ; if x = 0 then exit jra out .nosubstract rcf dec x ; decrement loop counter jrne execute ; if x = 0 then exit .out rlc {dividend+3} rlc {dividend+2} rlc {dividend+1} rlc {dividend} bres pbdr, #0 ;end of measurement ret
22/63 performance comparison between st72254 and pic16f876 6.17 16mul pic16 note: the source code is taken from a microchip application note. 6.18 16mul st72 test: bsf portb,0 ;beginning of measurement ;****************************************** ; double precision multiply ( 16x16 -> 32 ) ; ( accb*acca -> accb,accc ) ; 32 bit output ;with high word in accb ( accbhi,accblo ) ;and low word in accc ( accchi,accclo ). movlw .16 ; for 16 shifts movwf temp movf accbhi,w ;move accb to accd movwf accdhi movf accblo,w movwf accdlo clrf accbhi clrf accblo mloop: rrf accdhi, f ;rotate d right rrf accdlo, f btfss status,c ;need to add? goto no_add ;------------------------ ; addition ( accb + acca -> accb ) movf accalo,w addwf accblo, f ;add lsb btfsc status,c ;add in carry incf accbhi, f movf accahi,w addwf accbhi, f ;add msb movlw 0 ;------------------------ no_add: rrf accbhi, f rrf accblo, f rrf accchi, f rrf accclo, f decfsz temp, f ;until all bits checked goto mloop ;***************************************** bcf portb,0 ;end of measurement return .test bset pbdr, #0 ;beginning of measurement ld x, op2 ld a, op1 mul x, a ld res, x ld {res + 1}, a ld x, {op1 + 1} ld a, {op2 + 1} mul x, a ld {res + 2}, x ld {res + 3}, a ld x, op1 ld a, {op2 + 1} mul x, a add a, {res + 2} ld {res + 2}, a ld a, x adc a, {res + 1} ld {res + 1}, a ld a, res adc a, #0 ld res, a ld x, op2 ld a, {op1 + 1} mul x, a add a, {res + 2} ld {res + 2}, a ld a, x adc a, {res + 1} ld {res + 1}, a ld a, res adc a, #0 ld res, a bres pbdr, #0 ;end of measurement ret
23/63 performance comparison between st72254 and pic16f876 7 source code of the c routines 7.1 commnlib.h /**************************************************************************** * module: commnlib.h *****************************************************************************/ #ifndef common_lib_h #define common_lib_h /**** constant definitions ***/ #define true 1 #define false 0 #define ok 1 #define fault 0 /**** macro definitions ***/ /*-------------------------*/ /* bit manipulation macros */ /*-------------------------*/ #define setbit(x,y) (x) |= (y) #define clrbit(x,y) (x) &= ~(y) #define toglbit(x,y) ((x) ^= (y)) #define testbit(x,y) ((x) & (y)) #endif /* common_lib_h */ 7.2 file1.h #ifndef file1_h #define file1_h #ifdef file1_c #define extern_pfx #else #define extern_pfx extern #endif enum event_type { /** system events */ event_one, event_two, event_three, event_four, event_five, event_six, event_seven, event_eight, event_nine, event_ten, event_eleven, event_twelve, event_thirteen, event_fourteen, event_fifteen, event_sixteen };
24/63 performance comparison between st72254 and pic16f876 /****************************************************************************** private function prototypes *****************************************************************************/ /* announce_event connects event announcements to registered responses */ extern_pfx void announce_event(enum event_type newevent, unsigned char data); extern_pfx void announce_event1(enum event_type newevent); #undef extern_pfx 7.3 file1.c /***************************** file1.c *********************************/ #define file1_c #include ocommnlib.ho #include ofile1.ho #include ofile2.ho #include ofile3.ho #ifdef pwr_antenna_support #include oantenna.ho #endif void announce_event(enum event_type newevent, unsigned char data) { unsigned char temp_var1; unsigned char temp_var2; unsigned int temp_var3; unsigned int temp_var4; temp_var1 = 0; temp_var2 = 0; temp_var3 = 0; temp_var4 = 0; switch (newevent) { case event_one: file2_function1(data); setbit(global_1, 0x01); break; case event_two: file2_function2(data); clrbit(global_18, 0x02); break; case event_three: file2_function3(data); setbit(global_19, 0x04); break; case event_four: file2_function3(data); file2_function4(); clrbit(global_4, 0x10); break; case event_five: file2_function3(data); file2_function4(); clrbit(global_15, 0x20);
25/63 performance comparison between st72254 and pic16f876 case event_six: file2_function3(data); file2_function4(); file2_function5(); file2_function6(); file2_function7(); file2_function8(); file2_function9(); file2_function10(); file2_function11(1); #ifdef pwr_antenna_support global_19 = file2_function12(3); global_18 = file2_function13(2); file2_function14(7); file2_function15(); file2_function16(); #endif file2_function17(); file2_function18(); file2_function19(); file2_function20(); file2_function21(sizeof sample_array, &sample_array[0]); file2_function22(0, aux_on); file2_function23(param3); setbit(global_12, 0x01); break; case event_seven: file2_function3(data); file2_function4(); file2_function5(); file2_function6(); file2_function7(); file2_function8(); file2_function9(); file2_function10(); file2_function11(4); global_7 = file2_function12(2); global_9 = file2_function13(3); global_4 = file2_function14(9); file2_function15(); file2_function16(); file2_function17(); file2_function18(); file2_function19(); file2_function20(); file2_function21(sizeof sample_array, &sample_array[0]); file2_function22(0, aux_on); file2_function23(param7); global_3 = 99; break; case event_eight: file2_function3(data); file2_function4(); file2_function5(); file2_function6();
26/63 performance comparison between st72254 and pic16f876 file2_function7(); file2_function8(); file2_function9(); file2_function10(); file2_function11(9); global_5 = file2_function12(2); global_7 = file2_function13(1); file2_function14(4); file2_function15(); file2_function16(); file2_function17(); file2_function18(); file2_function19(); file2_function20(); file2_function21(sizeof sample_array, &sample_array[0]); file2_function22(10, 0); file2_function23(param10); break; case event_nine: file2_function3(data); file2_function4(); file2_function5(); file2_function6(); file2_function7(); file2_function8(); file2_function9(); file2_function10(); file2_function11(2); sample_array[4] = file2_function12(2); sample_array[3] = file2_function13(1); global_4 = file2_function14(5); file2_function15(); file2_function16(); file2_function17(); file2_function18(); file2_function19(); file2_function20(); file2_function22(20, 5); file2_function23(param13); global_4 = 65535; break; case event_ten: file2_function11(2); temp_var2 = file2_function12(22); temp_var3 = file2_function13(1); temp_var4 = file2_function14(100); global_13 = temp_var4; global_12 = temp_var3; global_11 = temp_var2; global_4 = temp_var4; file2_function22(2220, 4); break; case event_eleven: file2_function3(data); file2_function4();
27/63 performance comparison between st72254 and pic16f876 break; case event_twelve: file2_function1(4); file2_function2(3); break; case event_thirteen: file2_function5(); file2_function6(); break; case event_fourteen: case event_fifteen: file2_function6(); file2_function7(); break; default: file2_function3(data); file2_function4(); file2_function5(); file2_function6(); file2_function7(); file2_function8(); file2_function9(); file2_function10(); file2_function11(7); file2_function12(115); file2_function13(1); if (global_5 > 9) { file2_function14(5); file2_function15(); file2_function16(); } else if ((global_4) && (global_3 & 0x01)) { file2_function17(); file2_function18(); file2_function19(); file2_function20(); } file2_function23(param13); break; } return; } void announce_event1(enum event_type newevent) { announce_event(newevent, 0); return; }
28/63 performance comparison between st72254 and pic16f876 7.4 file2.h /****************************************************************************** include files *****************************************************************************/ /******************************************************************************/ #ifndef file2_h #define file2_h #ifdef file2_c #define extern_pfx #else #define extern_pfx extern #endif /****************************************************************************** public constant definitions *****************************************************************************/ #define param1 0 #define param2 1 #define param3 10 #define param4 20 #define param5 30 #define param6 40 #define param7 50 #define param8 60 #define param9 70 #define param10 80 #define param11 90 #define param12 100 #define param13 110 #define param14 120 #define param15 130 #define aux_on 0x01 #define aux_off 0x02 #define aux_reset 0x03 #define request_status 0x04 #define aux_diag 0x05 #define aux_null_state 0x0f #define aux_sw_version 0x10 extern_pfx unsigned char global_1; extern_pfx unsigned char global_2; extern_pfx unsigned char global_3; extern_pfx unsigned int global_4; extern_pfx unsigned char global_5; extern_pfx unsigned char global_6; extern_pfx unsigned char global_7; extern_pfx unsigned char global_8; extern_pfx unsigned char global_9; extern_pfx unsigned char global_10; extern_pfx unsigned char global_11; extern_pfx unsigned char global_12; extern_pfx unsigned char global_13; extern_pfx unsigned char global_14; extern_pfx unsigned char global_15; extern_pfx unsigned char global_16; extern_pfx unsigned char global_17;
29/63 performance comparison between st72254 and pic16f876 extern_pfx unsigned char global_18; extern_pfx unsigned char global_19; extern_pfx unsigned char global_20; extern_pfx unsigned char global_21; extern_pfx unsigned char sample_array[25]; extern_pfx unsigned char sample_array2[25]; extern_pfx void file2_function1(unsigned char dummy_param); extern_pfx void file2_function2(unsigned char dummy_param); extern_pfx void file2_function3(unsigned char dummy_param); extern_pfx void file2_function4(void); extern_pfx unsigned char file2_function5(void); extern_pfx void file2_function6(void); extern_pfx void file2_function7(void); extern_pfx void file2_function8(void); extern_pfx void file2_function9(void); extern_pfx void file2_function10(void); extern_pfx unsigned char file2_function11(unsigned char dummy_param); extern_pfx unsigned char file2_function12(unsigned char dummy_param); extern_pfx unsigned int file2_function13(unsigned char dummy_param); extern_pfx unsigned int file2_function14(unsigned char dummy_param); extern_pfx void file2_function15(void); extern_pfx void file2_function16(void); extern_pfx void file2_function17(void); extern_pfx void file2_function18(void); extern_pfx void file2_function19(void); extern_pfx void file2_function20(void); extern_pfx void file2_function21(unsigned char msg_size, unsigned char msg[]); extern_pfx void file2_function22(unsigned int aux_comm_timeout, unsigned char retry_txmsg); extern_pfx void file2_function23(unsigned char dummy_param); #undef extern_pfx 7.5 file2.c #define file2_c /**** include files ***/ #include ocommnlib.ho #include ofile1.ho #include ofile2.ho #include ofile3.ho #ifdef pwr_antenna_support #include oantenna.ho #endif #define scp_speed_msg 0x08 #define scp_opt 0x01 #define dsp_opt 0x02 #define tape_opt 0x04 #define rds_opt 0x08 #define clock_opt 0x10 #define phone_opt 0x20 #define cddj_opt 0x40 #define sample_disabled 0x01 #define max_speed_detect 241 #define min_speed_detect 16
30/63 performance comparison between st72254 and pic16f876 #define max_compensation_level20 #define sample_plus 0x20 #define aux_init_wait 0 #define aux_ready 1 #define aux_diag_mode 2 #define aux_reset_wait 3 #define aux_shutdown_wait 4 #define aux_shutdown_fail 5 #define aux_shutdown 6 #define user1 0 #define user2 1 #define pr_store_pending 2 #define pr_store_not_pending 3 #define int_mask 0x01 /* make sure static is handled by compiler. does it show up in link map ? */ static unsigned char radio_options; static unsigned char sample_volume; static unsigned char sample_volume_compensation; static unsigned char sample_comp_level; static unsigned char sample_flags; static unsigned char button_table[4]; static unsigned char button_time[4]; static unsigned char button_matrix_flags; static unsigned char user; static unsigned char presetx; unsigned char speed_int_register; unsigned char rx_scp_speed; unsigned char sample_array3[10]; /****************************************************************************** code - private functions *****************************************************************************/ void pr_write_eeprom_preset(unsigned char user1, unsigned char presetx1, unsigned char band1); unsigned char inspect_radio_options(void); unsigned char inspect_scp_msg_pending_flags(void); /****************************************************************************** code - public functions *****************************************************************************/ void file2_function1(unsigned char dummy_param) { global_4 = 0x77 - dummy_param; if (testbit(global_3, 0x02)) { clrbit(global_15, 0x01); } } void file2_function2(unsigned char dummy_param) { global_1 = 0x77 - dummy_param; if (testbit(global_3, 0x02)) { setbit(global_17, 0x01); }
31/63 performance comparison between st72254 and pic16f876 } void file2_function3(unsigned char dummy_param) { global_3 = 255 - (2 * dummy_param); if (testbit(global_5, 0x02)) { setbit(global_19, 0x01); } } void file2_function4(void) { global_4 = 255; if (testbit(global_5, 0x02)) { setbit(global_20, 0x01); } } unsigned char file2_function5(void) { global_5 = 255; if (testbit(global_6, 0x02)) { clrbit(global_17, 0x01); } for (presetx = 0; presetx < 6; presetx++) { global_1 = sample_array[presetx]; /*---------------------------*/ global_5 = sample_array[presetx]; if (((global_5 == user1) || (user == user2)) && (global_15 <= 2)) { pr_write_eeprom_preset(user, presetx, global_15); return (pr_store_pending);/* still need to continue check */ } /*---------------------------*/ if (global_15 <= 2) { pr_write_eeprom_preset(user, presetx, global_15); return (pr_store_pending);/* still need to continue check */ } else /* invalid/empty */ /* global_5 = global_4; } } /*else never found any valid data to store */ return (pr_store_not_pending); } void pr_write_eeprom_preset(unsigned char user1, unsigned char presetx1, unsigned char band1) { if (user1 > 1) { setbit(global_9, 0x01); global_8 = presetx1; } else {
32/63 performance comparison between st72254 and pic16f876 clrbit(global_19, 0x20); global_7 = band1; } } void file2_function6(void) { copy_array(&sample_array[0], &sample_array3[0], sizeof sample_array); } void file2_function7(void) { copy_array(&sample_array[0], &sample_array3[0], sizeof sample_array); } void file2_function8(void) { unsigned char local_temp; local_temp = check_if_array_same(&sample_array[0], &sample_array2[0], sizeof sample_array); if (local_temp == 0) { setbit(global_9, 0x04); } } /* sample while loop */ void file2_function9(void) { unsigned char local_temp; unsigned char delay_count; local_temp = check_if_array_same(&sample_array[0], &sample_array2[0], sizeof sample_array); if (local_temp == 0) { setbit(global_7, 0x40); } setbit(global_5, 0x04); delay_count = 18;/* wait for transmit to end. (g) */ while (testbit(global_5, 0x04) && --delay_count);/* dummy wait */ if (delay_count == 0) { return; } global_19 = 1; } void file2_function10(void) { unsigned char local_temp; unsigned char temp_count; unsigned int ee_crc_temp; local_temp = check_if_array_same(&sample_array[0], &sample_array2[0], sizeof sample_array); temp_count = inspect_radio_options(); ee_crc_temp = temp_count + 1000; if (local_temp == 0) { global_4 = ee_crc_temp;
33/63 performance comparison between st72254 and pic16f876 setbit(global_7, 0x40); } } unsigned char file2_function11(unsigned char dummy_param) { unsigned char local_one; local_one = 0; if (dummy_param < 25) { local_one = 1; } else if ((dummy_param > 55) && (dummy_param < 75)) { local_one = 0; } return (local_one); } unsigned char file2_function12(unsigned char dummy_param) { unsigned char local_two; unsigned char local_three; local_two = (dummy_param + 55) - 10; local_three = 0x55; clrbit(local_three, 0x01); if (local_two < 25) { setbit(local_three, 0x02); } else if ((local_two > 55) && (local_two < 75)) { setbit(local_three, (0x04 | 0x20)); } else if (local_two == 45) { setbit(local_three, 0x08); } if ((testbit(local_three, 0x04)) || (testbit(local_three, 0x02))) { setbit(local_three, 0x01); } return (local_three); } unsigned int file2_function13(unsigned char dummy_param) { unsigned int local_one; switch (dummy_param) { case param1: local_one = 1000; dummy_param++; break; case param2: local_one = 1200; break; case param3:
34/63 performance comparison between st72254 and pic16f876 local_one = 2400; break; default: local_one = 7000; dummy_param++; break; } global_9 = dummy_param; return (local_one); } unsigned char inspect_radio_options(void) { return (radio_options); } unsigned char inspect_scp_msg_pending_flags(void) { return (global_3); } /* function with divides, long and math. function returns char when it is supposed to return int. see if value promoted correctly. */ unsigned int file2_function14(unsigned char dummy_param) { unsigned char numerator, speed, speed_last; unsigned int temp; numerator = 0; speed = 0; speed_last = 0; temp = 0; if (testbit(global_1, sample_disabled)) return (0); if (inspect_radio_options() & scp_opt) { if (inspect_scp_msg_pending_flags() & scp_speed_msg) { temp = rx_scp_speed / 128; clrbit(global_3, scp_speed_msg); if (temp > max_speed_detect) temp = max_speed_detect; speed_last = temp; } } else { if (global_2 == 0) { clrbit(global_3, 0x01); if (global_1) { global_3 = global_1 - 1; } } if (global_1) --global_1; if ((!testbit(speed_int_register, int_mask)) && (dummy_param > 5))
35/63 performance comparison between st72254 and pic16f876 { temp = (unsigned long) 221814 / (unsigned long) (global_3 - global_1); if (temp > max_speed_detect)/* limit */ temp = max_speed_detect; speed_last = temp; } } speed = speed_last; /* no compensation if < */ if (speed < min_speed_detect) speed = min_speed_detect; speed = speed - min_speed_detect; /* calculates compensation based on user set level */ switch (sample_comp_level) { case 7: numerator = 93; break; case 6: numerator = 78; break; case 5: numerator = 66; break; case 4: numerator = 51; break; case 3: numerator = 42; break; case 2: numerator = 34; break; case 1: numerator = 23; break; default: numerator = 0; } sample_volume = ((numerator * speed) / 256); if (sample_volume > max_compensation_level) sample_volume = max_compensation_level; /* this part filters the calculated compensation for output */ if (sample_volume < sample_volume_compensation) { if (!testbit(sample_flags, sample_plus)) --sample_volume_compensation; else clrbit(sample_flags, sample_plus); } if (sample_volume > sample_volume_compensation) { if (testbit(sample_flags, sample_plus)) ++sample_volume_compensation;
36/63 performance comparison between st72254 and pic16f876 else setbit(sample_flags, sample_plus); } return (speed); } void file2_function15(void) { global_3 = (global_2 * 5); global_4 = global_5; } void file2_function16(void) { global_5 = ((global_2 * 25) + 55) - 45; global_7 = global_5 & 0x01; } /* for loop implementation, initialization, optimization */ void file2_function17(void) { unsigned char i; /* clear all button ram */ for (i = 0; i < 4; i++) { button_table[i] = 0; button_time[i] = 0; } button_matrix_flags = 0; } /* table search */ void file2_function18(void) { unsigned char table_index; table_index = 0; while (table_index < 15) { if (sample_array2[table_index] == 0) break; else table_index++; } global_8 = table_index; } void file2_function19(void) { unsigned char index; while (global_4 > 0) { if (sample_array2[1] == 1) { global_4--; /* move remaining buttons up in queue */ for (index = 0; index < global_4; index++) { sample_array2[index] = sample_array2[index + 1]; } }
37/63 performance comparison between st72254 and pic16f876 else break; /* stop at first failure */ } } /* check if constant gets pulled out of for loop in optimization */ void file2_function20(void) { unsigned char index; /* clear button_pending_queue */ for (index = 0; index < sizeof sample_array2; index++) { sample_array2[index] = 5 + global_5; } global_4 = (100 - 5) * 2; global_10 = 5 + global_3; } /* typical state machine manager and array passing, array manipulation */ void file2_function21(unsigned char msg_size, unsigned char msg[]) { switch (msg[0]) { case aux_off: case aux_on: case aux_reset: case aux_diag: case aux_null_state: if (msg_size == 1) { global_7 = msg[0]; } if (global_7 == aux_reset) { file2_function2(global_3); ; /* null statement on purpose */ } else if ((global_8 == aux_ready) && ((global_7 != aux_on) || (global_5 != 5))) { /* announce_event1(event_two) */ ; /* announce_event1(event_one) */ ;/* do not call events that use 21 */ } else if ((global_8 == aux_diag_mode) && (global_7 == aux_diag)) { file2_function3(4); } else if ((global_8 == aux_shutdown) || (global_8 == aux_shutdown_fail))/* error condition */ { file2_function4(); setbit(global_1, 0x02); } break; case aux_sw_version: if (msg_size == 4) {
38/63 performance comparison between st72254 and pic16f876 sample_array[0] = msg[1]; sample_array[1] = msg[2]; sample_array[2] = msg[3]; } break; default: sample_array[4] = 0; clrbit(global_1, 0x80); break; } /* end switch(msg[0]) */ return; } void file2_function22(unsigned int aux_comm_timeout, unsigned char retry_txmsg) { if (aux_comm_timeout != 0) { if ((--global_4) == 0) { if (global_8 == aux_init_wait) /* announce_event1(event_two) */ ; else if (global_8 == aux_diag_mode) /* announce_event1(event_three) */ ; if (global_8 != aux_shutdown_wait) /* announce_event(event_two,3) */ ; else /* announce_event(event_three,7) */ ; } else { switch (retry_txmsg) { case aux_on: case aux_off: case aux_diag: setbit(global_9, 0x04); break; case request_status: clrbit(global_10, 0x40); break; } global_9 = global_1; global_1 = global_2; global_3 = global_5; } } return; } /* else and if do the same thing. see if compiler optimizes */ void file2_function23(unsigned char dummy_param) { if (dummy_param == 7) { fill_byte_array(sample_array, sizeof sample_array, 55); } else
39/63 performance comparison between st72254 and pic16f876 { fill_byte_array(sample_array, sizeof sample_array, 55); } } 7.6 file3.h /***************************************************************************** * * module: utility.h *****************************************************************************/ #ifndef file3_h #define file3_h #ifdef file3_c #define extern_pfx #else #define extern_pfx extern #endif /****************************************************************************** constant definitions *****************************************************************************/ /* return values for function check_if_arrays_same */ #define arrays_different 2 #define arrays_same 1 /* defines used in convert_check */ #definelowercase_a 0x61 #define lowercase_z 0x7a #define lower_to_uppercase0x20 #define radio_text_dollar 0xab #define dollar_sign 98 #define generator_polynomial 0x1081 /****************************************************************************** global variable definitions *****************************************************************************/ /* hex to bcd conversion*/ extern_pfx unsigned char convert_value[3]; /****************************************************************************** public function prototypes *****************************************************************************/ /* return values are arrays_same and arrays_different */ extern_pfx unsigned char check_if_array_same(unsigned char *first_array, unsigned char *second_array, unsigned char array_size);/* compare two arrays */ /* copies one array to another */ extern_pfx void copy_array(unsigned char *array_to_be_copied_from, unsigned char *array_to_be_copied_into, unsigned char array_size); /* copy one array into another */ /* fills array with supplied value */ extern_pfx void fill_byte_array(unsigned char *array_start_ptr, unsigned char array_size,
40/63 performance comparison between st72254 and pic16f876 unsigned char fill_value); /* fills array with ascii 0x20 i.e, blank */ extern_pfx void blank_selected_buffer(unsigned char *array_to_be_blanked, unsigned char array_length); /* checks if the character is lower case converts it to upper case and checks for rbds dollar which is located different than the ascii dollar. blanks out all other chars if less then space_char(0x20) or greater than alpha_z (upper case z) */ extern_pfx void blank_selected_buffer(unsigned char *array_to_be_blanked, unsigned char array_length); /* convert check is used to check if all characters in an array are displayable * accroding to the rbds characters which is similar to ascii characters except * for some characters. order of check conversions done * 1. if characters between lowercase a to z converts to upper case * 2. check for dollar sign as out of range of check * 3. blank characters less then (space_char ox20) or greater than (alpha_z) as * none displayable character */ extern_pfx void convert_check(unsigned char *array_to_be_checked, unsigned char array_length); /* converts a unsigned integer to bcd and places it in an array of 3 bytes byte 0 being the most significant and byte 2 the least significant return value: global: convert_value[3] the output is a global array which is cleared each time the function is run so the value must be consumed as soon as the function is run. convert_value[0] most significant byte bcd convert_value[1] next significant byte bcd convert_value[2] least significant byte bcd */ extern_pfx void convert_hex_2_bcd(unsigned char value_to_convert); extern_pfx unsigned int generate_crc(unsigned char *address, unsigned char number_of_bytes, unsigned int current_crc); #undef extern_pfx 7.7 file3.c /***************************************************************************** * * module: utility.c *****************************************************************************/ #define file3_c /****************************************************************************** include files *****************************************************************************/ #include ocommnlib.ho #include ofile3.ho #include ofile4.ho unsigned char sample_array4[5]; /****************************************************************************** code - public functions
41/63 performance comparison between st72254 and pic16f876 *****************************************************************************/ /***************************************************************************** * * function: copy_array* *****************************************************************************/ void copy_array(unsigned char *array_to_be_copied_from, unsigned char *array_to_be_copied_into, unsigned char array_size) { unsigned char i; for (i = 0; i < array_size; i++) { array_to_be_copied_into[i] = array_to_be_copied_from[i]; } } /* end of function copy_array */ /***************************************************************************** * * function: check_if_array_same* *****************************************************************************/ unsigned char check_if_array_same(unsigned char *first_array, unsigned char *second_array, unsigned char array_size) { unsigned char i; for (i = 0; i < array_size; i++) { if (first_array[i] != second_array[i]) { return (arrays_different); } } return (arrays_same); } /* end function */ /***************************************************************************** * * function: fill_byte_array* *****************************************************************************/ /* usage array name (ie., start address) as first argument and sizeof as second */ void fill_byte_array(unsigned char *array_start_ptr, unsigned char array_size, unsigned char fill_value) { while (array_size--) *array_start_ptr++ = fill_value; } /* end of function fill_byte_array */ /****************************************************************************/ /* * function: blank_selected_buffer * ***************************************************************************/ void blank_selected_buffer(unsigned char *array_to_be_blanked, unsigned char array_length) { fill_byte_array(&array_to_be_blanked[0], array_length, space_char); } /****************************************************************************/ /*
42/63 performance comparison between st72254 and pic16f876 * function: convert_hex_2_bcd * *****************************************************************************/ void convert_hex_2_bcd(unsigned char value_to_convert) { unsigned char value_left; fill_byte_array(&sample_array4[0], 3, 0x00); if (value_to_convert <= 9) sample_array4[2] = value_to_convert; else { sample_array4[2] = value_to_convert % 0x0a; if (value_to_convert <= 99) sample_array4[1] = value_to_convert / 0x0a; else { value_left = value_to_convert / 0x0a; sample_array4[1] = value_left % 0x0a; sample_array4[0] = value_left / 0x0a; } } } /* intensive calculation. look for processing cycles and rom - ram */ unsigned int generate_crc(unsigned char *address, unsigned char number_of_bytes, unsigned int current_crc) { unsigned char *bound_address; unsigned char pc; unsigned char q; bound_address = address + number_of_bytes; while (address < bound_address) { pc = *address++; q = (current_crc ^ pc) & 0x0f;/* lower nibble */ current_crc = (current_crc >> 4) ^ (q * generator_polynomial); q = (current_crc ^ (pc >> 4)) & 0x0f;/* high nibble */ current_crc = (current_crc >> 4) ^ (q * generator_polynomial); } return (current_crc); } void convert_check(unsigned char *array_to_be_checked, unsigned char array_length) { unsigned char i; for (i = 0; i < array_length; i++) { if ((array_to_be_checked[i] >= lowercase_a) && (array_to_be_checked[i] <= lowercase_z)) array_to_be_checked[i] = array_to_be_checked[i] - lower_to_uppercase; else if (array_to_be_checked[i] == radio_text_dollar) array_to_be_checked[i] = dollar_sign; else if ((array_to_be_checked[i] > lowercase_z) || (array_to_be_checked[i] < space_char)) array_to_be_checked[i] = space_char; }
43/63 performance comparison between st72254 and pic16f876 7.8 file4.h #ifndef file4_h #define file4_h #ifdef file4_c #define extern_pfx #else #define extern_pfx extern #endif /************************************************************************/ /* * file char_def.h: character definitions for use with display load messages */ /************************************************************************/ /* * constant definitions */ /* lower message window -- ascii codes */ /* numbers 0 through 9 */ #define zero 48 #define one 49 #define two 50 #define three 51 #define four 52 #define five 53 #define six 54 #define seven 55 #define eight 56 #define nine 57 /* letter a through z (all caps) */ #define alpha_a 65 #define alpha_b 66 #define alpha_c 67 #define alpha_d 68 #define alpha_e 69 #define alpha_f 70 #define alpha_g 71 #define alpha_h 72 #define alpha_i 73 #define alpha_j 74 #define alpha_k 75 #define alpha_l 76 #define alpha_m 77 #define alpha_n 78 #define alpha_o 79 #define alpha_p 80 #define alpha_q 81 #define alpha_r 82 #define alpha_s 83 #define alpha_t 84 #define alpha_u 85 #define alpha_v 86 #define alpha_w 87 #define alpha_x 88 #define alpha_y 89
44/63 performance comparison between st72254 and pic16f876 #define alpha_z 90 /* definitions of special symbols for use in message window */ #define cust_ctr_bar 5 #define ctr_bar_lr_half_bar 6 #define ctr_bar_rt_half_bar 7 #define ctr_bar_lt_half_bar 8 #define lt_rt_half_bars 9 #define ctr_n_lt_bar_dash 10 #define ctr_n_rt_bar_dash 11 #define alpha_i_dash 12 #define lt_bar_sdash_lt 13 #define lt_bar_ldash 14 #define rt_bar_sdash_lt 15 #define rt_bar_ldash 16 #define ctr_bar_sdash_lt 17 #define ctr_bar_sdash_rt 18 #define half_r_bar 19 #define l_and_half_r_bar 20 #define half_l_bar 21 #define dbl_bar 22 #define up_arrow 23 #define down_arrow 24 #define sdash_rt 25 #define end_bar_star 26 #define end_bar 27 /* segments, segments b,c, and d */ #define l_bar 28 #define r_bar 29 #define sdash_lt 30 #define bar_star 31 #define space_char 32 #define exclam_pt 33 #define dbl_quote 34 #define number_hash 35 #define dollar_char 36 #define percent_char 37 #define ampersand 38 #define sngl_rt_quote 39 #define lt_paren 40 #define rt_paren 41 #define star 42 #define plus_char 43 #define comma_char 44 #define ldash 45 #define period 46 #define front_diag 47 #define colon 58 #define semicolon 59 #define lt_arrow 60 #define equal_char 61 #define rt_arrow 62 #define question_mark 63 #define circle_a_char 64 #define lt_sq_bracket 91 #define back_diag 92
45/63 performance comparison between st72254 and pic16f876 #define rt_sq_bracket 93 #define middle_bar 94 #define und_score 95 #define parrellel_char 96 #define small_o 97 #define dollar_sign 98 #define small_c 99 #define ctr_bar 124 /* characters defined for phone*/ /* all characters where previously defined therefore the characters for phone are mapped out twice ph char is the character received = denotes to the char in the table mapped out to and the equ denotes the character already existing so can be changed if any new custom characters required*/ #define ph_und_score 100 #define ph_bar_star 101 #define ph_end_bar_star 102 #define ph_end_bar 103 extern_pfx void audio_process(void); #undef extern_pfx 7.9 file4.c #define file4_c /****************************************************************************** include files *****************************************************************************/ #include ocommnlib.ho #include ofile4.ho #include ofile2.ho #include ofile3.ho const unsigned char lower_disp_msg_table[128][12] = { alpha_s, alpha_e, alpha_e, alpha_k, space_char, alpha_u, alpha_p, space_char, space_char, space_char, space_char, space_char,alpha_s, alpha_e, alpha_e, alpha_k, space_char, alpha_d, alpha_o, alpha_w, alpha_n, space_char, space_char, space_char,alpha_r, alpha_a, alpha_d, alpha_i, alpha_o, space_char, alpha_s, alpha_c, alpha_a, alpha_n, space_char, space_char,alpha_a, alpha_u, alpha_t, alpha_o, alpha_s, alpha_e, alpha_t, space_char, space_char, space_char, space_char, space_char,alpha_a, alpha_u, alpha_t, alpha_o, alpha_s, alpha_e, alpha_t, space_char, alpha_o, alpha_n, space_char, space_char,alpha_a, alpha_u, alpha_t, alpha_o, alpha_s, alpha_e, alpha_t, space_char, alpha_o, alpha_f, alpha_f, space_char,alpha_a, alpha_u, alpha_t, alpha_o, alpha_l, alpha_o, alpha_a, alpha_d, space_char, alpha_o, alpha_n, space_char,alpha_s, alpha_c, alpha_a, alpha_n, space_char, alpha_a, alpha_u, alpha_d, space_char, space_char, space_char, space_char,alpha_m, alpha_e, alpha_t, alpha_a, alpha_l, space_char, alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char,alpha_e, alpha_j, alpha_e, alpha_c, alpha_t, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_e, alpha_j, alpha_e, alpha_c, alpha_t, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r, space_char,alpha_l, alpha_o, alpha_a, alpha_d, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r, space_char, space_char,alpha_r, alpha_e, alpha_e, alpha_l, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r, space_char, space_char,alpha_n, alpha_o, space_char, alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char, space_char, space_char, space_char,alpha_s, alpha_p, alpha_k, alpha_r, space_char, alpha_s, alpha_h, alpha_o, alpha_r, alpha_t, space_char, space_char,alpha_p, alpha_h, alpha_o, alpha_n, alpha_e, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_f, alpha_a, alpha_s, alpha_t, space_char, alpha_f, alpha_w, alpha_d, space_char,alpha_c, alpha_d, space_char, alpha_f, alpha_a, alpha_s, alpha_t, space_char, alpha_r, alpha_e, alpha_v, space_char,alpha_s, alpha_h, alpha_u, alpha_f, alpha_f, alpha_l, alpha_e, space_char, alpha_o, alpha_n, space_char, space_char,alpha_s, alpha_h, alpha_u, alpha_f, alpha_f, alpha_l, alpha_e, space_char, alpha_o, alpha_f, alpha_f, space_char,alpha_s, alpha_h, alpha_u, alpha_f, alpha_f, alpha_l, alpha_e, space_char, space_char, space_char, space_char, space_char,alpha_f, alpha_o, alpha_c, alpha_u, alpha_s, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r, space_char,alpha_c, alpha_d, space_char, alpha_h, alpha_o, alpha_t, space_char, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_r, alpha_o, alpha_m, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r,alpha_c, alpha_o, alpha_m, alpha_m, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r, space_char, space_char,alpha_n, alpha_o, space_char, alpha_m,
46/63 performance comparison between st72254 and pic16f876 alpha_a, alpha_g, space_char, space_char, space_char, space_char, space_char, space_char,alpha_e, alpha_m, alpha_p, alpha_t, alpha_y, space_char, alpha_m, alpha_a, alpha_g, space_char, space_char, space_char, alpha_n, alpha_o, space_char, alpha_c, alpha_d, alpha_d, alpha_j, space_char, space_char, space_char, space_char, space_char,alpha_n, alpha_o, space_char, alpha_r, alpha_e, alpha_m, alpha_o, alpha_t, alpha_e, space_char, alpha_c, alpha_d,alpha_n, alpha_o, space_char, alpha_c, alpha_d, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_t, alpha_r, alpha_a, alpha_f, alpha_f, alpha_i, alpha_c, space_char, space_char, space_char, space_char, space_char,alpha_t, alpha_r, alpha_a, alpha_f, alpha_f, alpha_i, alpha_c, space_char, alpha_o, alpha_n, space_char, space_char,alpha_t, alpha_r, alpha_a, alpha_f, alpha_f, alpha_i, alpha_c, space_char, alpha_o, alpha_f, alpha_f, space_char,alpha_t, alpha_e, alpha_x, alpha_t, space_char, alpha_o, alpha_n, space_char, space_char, space_char, space_char, space_char,alpha_t, alpha_e, alpha_x, alpha_t, space_char, alpha_o, alpha_f, alpha_f, space_char, space_char, space_char, space_char,alpha_f, alpha_o, alpha_r, alpha_m, alpha_a, alpha_t, space_char, alpha_o, alpha_n, space_char, space_char, space_char,alpha_f, alpha_o, alpha_r, alpha_m, alpha_a, alpha_t, space_char, alpha_o, alpha_f, alpha_f, space_char, space_char,alpha_a, alpha_u, alpha_t, alpha_o, space_char, alpha_c, alpha_l, alpha_k, space_char, alpha_o, alpha_n, space_char,alpha_a, alpha_u, alpha_t, alpha_o, space_char, alpha_c, alpha_l, alpha_k, space_char, alpha_o, alpha_f, alpha_f,alpha_s, alpha_e, alpha_l, alpha_e, alpha_c, alpha_t, space_char, alpha_h, alpha_o, alpha_u, alpha_r, space_char,alpha_s, alpha_e, alpha_l, alpha_e, alpha_c, alpha_t, space_char, alpha_m, alpha_i, alpha_n, alpha_s, space_char,alpha_a, alpha_u, alpha_t, alpha_o, space_char, alpha_c, alpha_l, alpha_k, space_char, alpha_s, alpha_e, alpha_t,alpha_r, alpha_d, alpha_s, space_char, alpha_o, alpha_n, space_char, space_char, space_char, space_char, space_char, space_char,alpha_r, alpha_d, alpha_s, space_char, alpha_o, alpha_f, alpha_f, space_char, space_char, space_char, space_char, space_char,alpha_t, alpha_a, space_char, alpha_r, alpha_e, alpha_p, alpha_o, alpha_r, alpha_t, space_char, space_char, space_char,alpha_j, alpha_a, alpha_z, alpha_z, space_char, alpha_c, alpha_l, alpha_u, alpha_b, space_char, space_char, space_char,alpha_h, alpha_a, alpha_l, alpha_l, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_h, alpha_u, alpha_r, alpha_c, alpha_h, space_char, space_char, space_char, space_char, space_char, space_char,alpha_s, alpha_t, alpha_a, alpha_d, alpha_i, alpha_u, alpha_m, space_char, space_char, space_char, space_char, space_char,alpha_n, alpha_e, alpha_w, alpha_s, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_d, alpha_s, alpha_p, space_char, alpha_o, alpha_f, alpha_f, space_char, space_char, space_char, space_char, space_char,alpha_o, alpha_c, alpha_c, alpha_u, alpha_p, alpha_a, alpha_n, alpha_c, alpha_y, space_char, space_char, space_char,alpha_d, alpha_r, alpha_i, alpha_v, alpha_e, alpha_r, space_char, alpha_s, alpha_e, alpha_a, alpha_t, space_char,alpha_n, alpha_o, alpha_t, space_char, alpha_f, alpha_o, alpha_u, alpha_n, alpha_d, space_char, space_char, space_char,alpha_r, alpha_e, alpha_a, alpha_r, space_char, alpha_s, alpha_e, alpha_a, alpha_t, alpha_s, space_char, space_char,alpha_a, alpha_l, alpha_l, space_char, alpha_s, alpha_e, alpha_a, alpha_t, alpha_s, space_char, space_char, space_char,alpha_s, alpha_a, alpha_v, alpha_e, alpha_d, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_f, alpha_a, alpha_u, alpha_l, alpha_t, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_s, alpha_p, alpha_e, alpha_a, alpha_k, alpha_e, alpha_r, space_char, alpha_l, alpha_f, space_char, space_char,alpha_s, alpha_p, alpha_e, alpha_a, alpha_k, alpha_e, alpha_r, space_char, alpha_r, alpha_f, space_char, space_char,alpha_s, alpha_p, alpha_e, alpha_a, alpha_k, alpha_e, alpha_r, space_char, alpha_r, alpha_r, space_char, space_char,alpha_s, alpha_p, alpha_e, alpha_a, alpha_k, alpha_e, alpha_r, space_char, alpha_l, alpha_r, space_char, space_char,alpha_a, alpha_n, alpha_t, alpha_e, alpha_n, alpha_n, alpha_a, space_char, alpha_i, alpha_i, space_char, space_char,alpha_s, alpha_u, alpha_b, alpha_w, alpha_o, alpha_o, alpha_f, alpha_e, alpha_r, space_char, alpha_i, space_char,alpha_s, alpha_u, alpha_b, alpha_w, alpha_o, alpha_o, alpha_f, alpha_e, alpha_r, space_char, alpha_i, alpha_i,alpha_s, alpha_e, alpha_l, alpha_f, space_char, alpha_t, alpha_e, alpha_s, alpha_t, space_char, space_char, space_char,alpha_s, alpha_e, alpha_l, alpha_f, space_char, alpha_p, alpha_a, alpha_s, alpha_s, space_char, space_char, space_char,alpha_s, alpha_e, alpha_l, alpha_f, space_char, alpha_f, alpha_a, alpha_i, alpha_l, space_char, space_char, space_char,alpha_n, alpha_o, space_char, alpha_d, alpha_t, alpha_c, alpha_s, space_char, space_char, space_char, space_char, space_char,alpha_d, alpha_t, alpha_c, alpha_s, space_char, alpha_f, alpha_o, alpha_u, alpha_n, alpha_d, space_char, space_char,alpha_d, alpha_t, alpha_c, alpha_s, space_char, alpha_c, alpha_l, alpha_e, alpha_a, alpha_r, space_char, space_char,alpha_u, two, zero, zero, three, space_char, alpha_c, alpha_d, alpha_d, alpha_j, space_char, space_char,alpha_u, two, zero, zero, five, space_char, alpha_r, alpha_i, alpha_c, alpha_p, space_char, space_char,alpha_u, two, zero, zero, eight, space_char, alpha_p, alpha_h, alpha_o, alpha_n, alpha_e, space_char,alpha_u, one, zero, four, one, space_char, alpha_s, alpha_c, alpha_p, space_char, space_char, space_char,alpha_u, one, one, eight, zero, space_char, alpha_s, alpha_c, alpha_p, space_char, space_char, space_char,alpha_u, one, two, two, two, space_char, alpha_s, alpha_c, alpha_p, space_char, space_char, space_char,alpha_b, one, three, four, two, space_char, alpha_e, alpha_c, alpha_u, space_char, space_char, space_char,alpha_b, two, four, zero, one, space_char, alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char,alpha_b, two, four, zero, two, space_char, alpha_c, alpha_d, alpha_d, alpha_j, space_char, space_char,alpha_b, two, four, zero, three, space_char, alpha_c, alpha_d, alpha_d, alpha_j, space_char, space_char,alpha_b, two, four, zero, four, space_char, alpha_s, alpha_w, alpha_c, space_char, space_char, space_char,alpha_b, two, four, zero, five, space_char, alpha_c, alpha_d, space_char, alpha_h, alpha_o, alpha_t,alpha_b, two, four, zero, six, space_char, alpha_c, alpha_d, space_char, space_char, space_char, space_char,alpha_s, alpha_i, alpha_g, alpha_n, alpha_a, alpha_l, space_char, alpha_t, alpha_e, alpha_s, alpha_t, space_char,alpha_d, alpha_i, alpha_s, alpha_p, alpha_l, alpha_a, alpha_y, space_char, alpha_t, alpha_e, alpha_s, alpha_t,alpha_t, alpha_a, alpha_p, alpha_e, space_char, alpha_t, alpha_e, alpha_s, alpha_t, space_char, space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, alpha_f, alpha_a, alpha_i, alpha_l, space_char,
47/63 performance comparison between st72254 and pic16f876 space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, alpha_p, alpha_a, alpha_s, alpha_s, space_char, space_char, space_char,alpha_s, alpha_o, alpha_f, alpha_t, space_char, alpha_l, alpha_e, alpha_v, alpha_e, alpha_l, alpha_s, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, one, space_char, alpha_f, alpha_f, space_char, space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, two, space_char, alpha_f, alpha_f, space_char, space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, one, space_char, alpha_r, alpha_e, alpha_w, space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, two, space_char, alpha_r, alpha_e, alpha_w, space_char, space_char,alpha_c, alpha_d, space_char, alpha_s, alpha_e, alpha_e, alpha_k, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_t, alpha_r, alpha_k, space_char, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_s, alpha_c, alpha_a, alpha_n, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_r, alpha_o, alpha_m, space_char, alpha_d, alpha_i, alpha_s, alpha_k, space_char,alpha_c, alpha_d, space_char, space_char, space_char, space_char, alpha_f, alpha_f, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, space_char, space_char, space_char, alpha_r, alpha_e, alpha_v, space_char, space_char, space_char,alpha_c, alpha_d, space_char, space_char, space_char, alpha_s, alpha_e, alpha_e, alpha_k, space_char, space_char, space_char,alpha_c, alpha_d, space_char, space_char, space_char, alpha_t, alpha_r, alpha_k, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, space_char, space_char, alpha_s, alpha_c, alpha_a, alpha_n, space_char, space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char, space_char, alpha_p, alpha_l, alpha_a, alpha_y, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char, alpha_s, alpha_e, alpha_e, alpha_k, space_char, space_char,alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char, space_char, space_char, alpha_s, alpha_e, alpha_e, alpha_k,alpha_t, alpha_a, alpha_p, alpha_e, space_char, space_char, space_char, alpha_s, alpha_c, alpha_a, alpha_n, space_char,alpha_a, alpha_u, alpha_d, alpha_i, alpha_o, space_char, alpha_m, alpha_u, alpha_t, alpha_e, space_char, space_char,alpha_s, alpha_p, alpha_e, alpha_e, alpha_d, space_char, alpha_v, alpha_o, alpha_l, space_char, space_char, space_char,alpha_n, alpha_o, space_char, alpha_p, alpha_h, alpha_o, alpha_n, alpha_e, space_char, space_char, space_char, space_char,alpha_s, alpha_e, alpha_e, alpha_k, space_char, alpha_t, alpha_r, alpha_a, alpha_f, alpha_f, alpha_i, alpha_c,alpha_d, alpha_i, alpha_a, alpha_g, alpha_n, alpha_o, alpha_s, alpha_t, alpha_i, alpha_c, alpha_s, space_char,alpha_s, alpha_c, alpha_a, alpha_n, space_char, alpha_t, alpha_r, alpha_a, alpha_f, alpha_f, alpha_i, alpha_c,alpha_a, alpha_l, alpha_e, alpha_r, alpha_t, space_char, alpha_r, alpha_e, alpha_p, alpha_o, alpha_r, alpha_t,alpha_s, alpha_h, alpha_o, alpha_w, space_char, alpha_n, alpha_o, alpha_n, alpha_e, space_char, space_char, space_char,alpha_s, alpha_h, alpha_o, alpha_w, space_char, alpha_n, alpha_a, alpha_m, alpha_e, space_char, space_char, space_char,alpha_s, alpha_h, alpha_o, alpha_w, space_char, alpha_t, alpha_y, alpha_p, alpha_e, space_char, space_char, space_char,alpha_s, alpha_h, alpha_o, alpha_w, space_char, alpha_t, alpha_e, alpha_x, alpha_t, space_char, space_char, space_char,alpha_n, alpha_o, space_char, alpha_p, alpha_o, alpha_r, alpha_t, alpha_a, alpha_b, alpha_l, alpha_e, space_char,alpha_e, alpha_n, alpha_d, space_char, alpha_o, alpha_f, space_char, alpha_d, alpha_i, alpha_s, alpha_c, space_char,alpha_s, alpha_e, alpha_a, alpha_r, alpha_c, alpha_h, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r,alpha_b, alpha_a, alpha_d, space_char, alpha_d, alpha_i, alpha_s, alpha_c, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_e, alpha_r, alpha_r, alpha_o, alpha_r, space_char, space_char, space_char, space_char,alpha_n, alpha_o, space_char, alpha_t, alpha_r, alpha_k, space_char, alpha_f, alpha_o, alpha_u, alpha_n, alpha_d,space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char,alpha_c, alpha_d, space_char, alpha_f, alpha_a, alpha_i, alpha_l, alpha_u, alpha_r, alpha_e, space_char, space_char,alpha_n, alpha_o, space_char, alpha_r, alpha_d, alpha_s, space_char, space_char, space_char, space_char, space_char, space_char }; const unsigned char loudness_offset[] = {0, 0, 0, 0, 0, 0, 15, 15, 30, 30, 45, 45, 60, 60, 60, 60, 75, 75, 75, 75, 75, 75, 75, 75, 90, 105, 105, 120, 120, 135, 135, 150, 165, 180, 180}; const unsigned char bass_index[] = {18, 20, 22, 24, 26, 28, 30, 32, 34, 35, 36, 37, 38, 39, 40, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 37, 38, 39, 40, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 35, 36, 37, 38, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 33, 34, 35, 36, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 31, 32, 33, 34, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 30, 31, 32, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 28, 29, 30, 6, 8, 10, 12, 14, 16, 18, 20, 22, 23, 24, 25, 26, 27, 28, 6, 8, 10, 12, 14, 16, 18, 20, 21, 22, 23, 24, 25, 25, 26, 4, 6, 8, 10, 12, 14, 16, 18, 19, 20, 21, 22, 23, 23, 24, 4, 6, 8, 10, 12, 14, 16, 18, 19, 19, 20, 20, 21, 21, 22, 4, 5, 6, 8, 10, 12, 14, 16, 17, 18, 19, 20, 20, 21, 22,
48/63 performance comparison between st72254 and pic16f876 4, 5, 6, 8, 10, 12, 14, 16, 16, 17, 17, 18, 18, 19, 20}; const unsigned char treble_index[] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}; const unsigned int balance_table[] = {2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 1773, 1773, 1536, 1330, 997, 648, 364, 0}; const unsigned int fade_table[] = {0, 7, 27, 100, 205, 364, 561, 864, 997, 1330, 1536, 1536, 1773, 2047, 2047, 2047, 2047, 2047, 2047}; const unsigned char lower_win_even_digit_table[14] = { 42, /* seg a */ 3, /* seg b */ 7, /* seg c */ 12, /* seg d */ 8, /* seg e */ 4, /* seg f */ 6, /* seg g */ 1, /* seg h */ 0, /* seg j */ 2, /* seg k */ 5, /* seg m */ 10, /* seg n */ 11, /* seg p */ 9 /* seg r */ }; const unsigned char lower_win_odd_digit_table[14] = { 26, /* seg a */ 22, /* seg b */ 18, /* seg c */ 13, /* seg d */ 17, /* seg e */ 21, /* seg f */ 19, /* seg g */ 24, /* seg h */ 25, /* seg j */ 23, /* seg k */ 20, /* seg m */ 15, /* seg n */ 14, /* seg p */ 16 /* seg r */ }; struct btbf { unsigned char bass; unsigned char treble; unsigned char balance; unsigned char fade; }; struct btbf *audio; struct btbf btbf1; struct btbf btbf2; /* structure and table operation */ void audio_process(void) {
49/63 performance comparison between st72254 and pic16f876 btbf2.bass = bass_index[15]; btbf2.treble = treble_index[4]; btbf2.balance = balance_table[0]; btbf2.fade = fade_table[10]; if (btbf2.bass < 15) { /* update bass, then send the new bass value to the audio processing ic. */ ++btbf2.bass; } if (global_1 > 127) global_1 = 127;/* bounds check first */ copy_array(&(lower_disp_msg_table[global_1][0]), &sample_array[0], 12); if (global_5 > 127) global_5 = 127;/* bounds check first */ copy_array(&(lower_disp_msg_table[global_5][0]), &sample_array2[0], 12); if (global_21 > 127) global_21 = 127;/* bounds check first */ copy_array(&(lower_disp_msg_table[global_21][0]), &sample_array[0], 12); global_1 = 5; global_4 = balance_table[global_1] + fade_table[global_1]; global_7 = bass_index[global_1 + 2]; global_8 = treble_index[global_1 + 3]; copy_array(&bass_index[0], &sample_array[0], sizeof sample_array); global_9 = loudness_offset[5] + 5; if (global_9 > 55) { global_15 = lower_win_even_digit_table[6]; } else { global_17 = lower_win_odd_digit_table[12]; } copy_array(&(lower_disp_msg_table[global_5][0]), &sample_array2[0], 12); copy_array(&(lower_disp_msg_table[global_5][0]), &sample_array[0], 12); } 7.10 file5.h #ifndef file5_h #define file1_h #ifdef file5_c #define extern_pfx #else #define extern_pfx extern #endif #define cbench_case_1 1 #define cbench_case_2 2 #define cbench_case_3 3 #define cbench_case_4 4 #define cbench_case_5 5 #define cbench_case_6 6 #define cbench_case_7 7 #define cbench_case_8 8 #define cbench_case_9 9
50/63 performance comparison between st72254 and pic16f876 #define cbench_case_10 10 #define cbench_case_11 11 #define cbench_case_12 12 extern_pfx void file5_function1(void); extern_pfx void file5_function2(void); extern_pfx void file5_function3(void); extern_pfx void file5_function4(void); extern_pfx void file5_function5(void); extern_pfx void file5_function6(void); #undef extern_pfx 7.11 file5.c /* switch statement samples */ #define file5_c /****************************************************************************** include files *****************************************************************************/ #include ocommnlib.ho #include ofile2.ho #include ofile5.ho /* look for optimization in first two cases. cases in sequence also. see if switch table used */ void file5_function1(void) { switch (global_1) { case cbench_case_1: file2_function1(1); break; case cbench_case_2: file2_function1(1); break; case cbench_case_3: file2_function2(5); break; case cbench_case_4: file2_function3(5); break; case cbench_case_5: file2_function4(); break; default: file2_function4(); break; } } /* cases out of order. verify how much rom compared to function1 */ void file5_function2(void) { switch (global_2) { case cbench_case_2:
51/63 performance comparison between st72254 and pic16f876 file2_function1(1); break; case cbench_case_1: file2_function1(1); break; case cbench_case_4: file2_function3(5); break; case cbench_case_3: file2_function2(5); break; case cbench_case_5: file2_function4(); break; default: file2_function4(); break; } } /* several cases. reverse order */ void file5_function3(void) { switch (global_7) { case cbench_case_12: file2_function1(10); break; case cbench_case_11: file2_function1(1); break; case cbench_case_10: file2_function2(3); file2_function1(1); file2_function3(10); break; case cbench_case_9: file2_function2(5); break; case cbench_case_8: file2_function3(5); break; case cbench_case_5: file2_function4(); break; default: file2_function4(); break; } } /* just two cases here. check if it is more efficient than if */ void file5_function4(void) { switch (global_17) { case cbench_case_12:
52/63 performance comparison between st72254 and pic16f876 file2_function1(10); break; default: file2_function4(); break; } } /* 3 cases. check if it is efficient to use switch or if */ void file5_function5(void) { switch (global_19) { case cbench_case_1: file2_function1(10); break; case cbench_case_2: if ((global_9) && (global_1 & 0x01)) { file2_function4(); } break; default: file2_function4(); break; } } /* 12 cases. look for switch efficiency */ void file5_function6(void) { switch (global_4) { case cbench_case_1: file2_function1(1); break; case cbench_case_2: file2_function1(1); break; case cbench_case_3: file2_function2(5); break; case cbench_case_4: file2_function3(5); break; case cbench_case_5: file2_function4(); break; case cbench_case_6: file2_function6(); break; case cbench_case_7: file2_function7(); break; case cbench_case_8: file2_function8();
53/63 performance comparison between st72254 and pic16f876 break; case cbench_case_9: file2_function9(); break; case cbench_case_10: file2_function10(); break; case cbench_case_11: file2_function8(); break; case cbench_case_12: file2_function9(); break; default: file2_function10(); break; } 7.12 file6.h /****************************************************************************** include files /******************************************************************************/ #ifndef file6_h #define file6_h #ifdef file6_c #define extern_pfx #else #define extern_pfx extern #endif /****************************************************************************** public constant definitions *****************************************************************************/ extern_pfx unsigned char cbench_dat[4]; extern_pfx unsigned char cbench_syn[2]; extern_pfx unsigned char cbench_af_flags; extern_pfx unsigned char cbench_sync_flags; extern_pfx unsigned char cbench_bit_ctr; extern_pfx unsigned char bad_blk_ctr; extern_pfx unsigned char next_block; extern_pfx unsigned char max_bad_blocks; extern_pfx unsigned char cbench_ls1; extern_pfx unsigned char cbench_ms1; extern_pfx unsigned char cbench_ls2; extern_pfx unsigned char cbench_ms2; extern_pfx unsigned char cbench_x; extern_pfx unsigned char proceed_with_cbench_interrupt; extern_pfx unsigned char mbs_station_found; extern_pfx unsigned char cbench_nxt_rw_data; extern_pfx void cbench_block_sync(void); #undef extern_pfx
54/63 performance comparison between st72254 and pic16f876 7.13 file6.c /* check for matrix multiplication */ /******************************************************************************/ #define file6_c /**** include files ***/ #include ofile6.ho #include ocommnlib.ho #define bit_0 0x01 #define bit_1 0x02 #define bit_2 0x04 #define bit_3 0x08 #define bit_4 0x10 #define bit_5 0x20 #define bit_6 0x40 #define bit_7 0x80 /**** constant definitions ***/ /**** structure definitions ***/ /**** public variables */ /* look for matrix multiplication rom - ram and cycles see if 16 bit math used */ void cbench_block_sync(void) { proceed_with_cbench_interrupt = 0;/* int to do not contiune with interrupt */ cbench_ms2 = cbench_ms1; cbench_ls2 = cbench_ls1; cbench_ms1 = cbench_dat[1]; cbench_ls1 = cbench_dat[2]; cbench_dat[0] <<= 1;/* rotate datastream through buffer */ if (cbench_dat[1] & bit_7) cbench_dat[0] |= 1; cbench_dat[1] <<= 1; if (cbench_dat[2] & bit_7) cbench_dat[1] |= 1; cbench_dat[2] <<= 1; if (cbench_dat[3] & bit_7) cbench_dat[2] |= 1; cbench_dat[3] <<= 1; if (testbit(cbench_nxt_rw_data, 0x01)) cbench_dat[3] |= 1;/* put new cbench bit into 26 bit buffer */ clrbit(cbench_nxt_rw_data, 0x01); cbench_bit_ctr++;/* increment bit counter */ if ((testbit(cbench_sync_flags, 0x01)) || (testbit(cbench_sync_flags, 0x04))) { if (cbench_bit_ctr >= 25) { proceed_with_cbench_interrupt = 1; } } else { if (cbench_bit_ctr >= 26) { proceed_with_cbench_interrupt = 1; } }
55/63 performance comparison between st72254 and pic16f876 if (proceed_with_cbench_interrupt) { /* 10 bit checkword */ cbench_x = cbench_dat[0] & 0x03;/* upper 2 bits of checkword */ cbench_syn[1] = cbench_dat[1];/* lower 8 bits of checkword */ if (cbench_dat[3] & bit_0) { cbench_syn[1] ^= 0x1b; cbench_x ^= 0x03; } /* parity check matrix multiplication */ if (cbench_dat[3] & bit_1) { cbench_syn[1] ^= 0x8f; cbench_x ^= 0x03; } if (cbench_dat[3] & bit_2) { cbench_syn[1] ^= 0xa7; cbench_x ^= 0x02; } if (cbench_dat[3] & bit_4) { cbench_syn[1] ^= 0xee; cbench_x ^= 0x01; } if (cbench_dat[3] & bit_5) { cbench_syn[1] ^= 0xdc; cbench_x ^= 0x03; } if (cbench_dat[3] & bit_6) { cbench_syn[1] ^= 0x01; cbench_x ^= 0x02; } if (cbench_dat[3] & bit_7) { cbench_syn[1] ^= 0xbb; cbench_x ^= 0x01; } if (cbench_dat[2] & bit_0) { cbench_syn[1] ^= 0x76; cbench_x ^= 0x03; } if (cbench_dat[2] & bit_1) { cbench_syn[1] ^= 0x55; cbench_x ^= 0x03; } if (cbench_dat[2] & bit_2) { cbench_syn[1] ^= 0x13; cbench_x ^= 0x03; }
56/63 performance comparison between st72254 and pic16f876 if (cbench_dat[2] & bit_3) { cbench_syn[1] ^= 0x9f; cbench_x ^= 0x03; } if (cbench_dat[2] & bit_4) { cbench_syn[1] ^= 0x87; cbench_x ^= 0x02; } if (cbench_dat[2] & bit_6) { cbench_syn[1] ^= 0x6e; cbench_x ^= 0x01; } if (cbench_dat[2] & bit_7) { cbench_syn[1] ^= 0xdc; cbench_x ^= 0x02; } cbench_syn[0] = cbench_x; if (cbench_dat[3] & bit_3) cbench_syn[1] ^= 0xf7; if (cbench_dat[2] & bit_5) cbench_syn[1] ^= 0xb7; } /* end if cbench_bit_ctr >= 26 */ 7.14 file7.c /* switch statement samples */ #define file7_c /****************************************************************************** include files *****************************************************************************/ #include ocommnlib.ho #include ofile1.ho #include ofile2.ho #include ofile3.ho #include ofile4.ho #include ofile5.ho #include ofile6.ho #include ofile8.ho void main(void) { unsigned char main_temp; unsigned int main_temp2; /* init local variables */ main_temp = 5; main_temp2 = 200; /* init all globals from file filet2.h */ global_1 = 1; global_2 = 2; global_3 = 3;
57/63 performance comparison between st72254 and pic16f876 global_4 = 4; global_5 = 0; global_6 = 0; global_7 = 0; global_8 = 0; global_9 = 0; global_10 = 0; global_11 = 0; global_12 = 5; global_13 = 5; global_14 = 5; global_15 = 5; global_16 = 5; global_17 = 6; global_18 = 0xff; global_19 = 0xf0; global_20 = 0xf1; global_21 = 0x50; /* init file6 variables */ cbench_dat[0] = 0xfe; cbench_dat[1] = 0x54; cbench_dat[2] = 0xee; cbench_dat[3] = 0x11; cbench_syn[0] = 0x80; cbench_syn[1] = 0x43; cbench_af_flags = 0; cbench_sync_flags = 0x78; cbench_bit_ctr = 25;/* force syndrome calculation */ bad_blk_ctr = 3; next_block = 1; max_bad_blocks = 8; cbench_ls1 = 77; cbench_ms1 = 0x45; cbench_ls2 = 0x32; cbench_ms2 = 0x31; cbench_x = 1; proceed_with_cbench_interrupt = 1; mbs_station_found = 1; cbench_nxt_rw_data = 1; /* use functions in file 3.c */ blank_selected_buffer(&sample_array[0], sizeof sample_array); fill_byte_array(&sample_array2[0], sizeof sample_array2, 0x50); copy_array(&sample_array2[0], &sample_array[0], sizeof sample_array2); announce_event(event_one, 0); announce_event(event_two, 6); announce_event(event_three, 25); announce_event(event_four, 13); announce_event(event_five, 50); announce_event(event_six, 125); announce_event(event_seven, 250); announce_event(event_eight, 5); announce_event(event_nine, 12); announce_event(event_ten, 25); announce_event1(event_eleven); announce_event1(event_twelve);
58/63 performance comparison between st72254 and pic16f876 announce_event(event_thirteen, 7); announce_event(event_fourteen, 25); announce_event(event_fifteen, 25); announce_event(event_sixteen, 25); cbench_block_sync(); global_3 = file2_function5(); file2_function8(); file2_function9(); file2_function10(); if (file2_function11(2) == 1)/* look for optimization with return value of function */ { global_19 = file2_function12(5); } file2_function1(15); file2_function2(34); file2_function3(3); file2_function4(); main_temp = check_if_array_same(&sample_array[0], &sample_array2[0], 25); if (main_temp == arrays_different) { audio_process(); } else { convert_hex_2_bcd(45);/* result in sample_array4 */ } convert_hex_2_bcd(5); audio_process(); main_temp2 = generate_crc(&sample_array[0], sizeof sample_array, main_temp2); sample_array2[0] = dollar_sign; sample_array2[5] = lowercase_a; sample_array2[9] = lowercase_z; convert_check(&sample_array2[0], sizeof sample_array2); global_1 = cbench_case_5; file5_function1(); global_2 = cbench_case_3; file5_function2(); global_7 = cbench_case_10; file5_function3(); file5_function4();/* uses global_17 */ global_19 = cbench_case_2; file5_function5(); global_4 = cbench_case_9; file5_function6(); file8_function1(); file8_function2(); file8_function3(); file8_function4(); file8_function5(); file8_function6(); cbench_dat[0] = 0x0e; cbench_dat[1] = 0x04; cbench_dat[2] = 0x1e; cbench_dat[3] = 0x21; cbench_block_sync();
59/63 performance comparison between st72254 and pic16f876 cbench_block_sync(); cbench_block_sync(); cbench_block_sync(); } 7.15 file8.h /****************************************************************************** include files *******************************************************************************/ #ifndef file8_h #define file8_h #ifdef file8_c #define extern_pfx #else #define extern_pfx extern #endif /****************************************************************************** public constant definitions *****************************************************************************/ extern_pfx void file8_function1(void); extern_pfx void file8_function2(void); extern_pfx void file8_function3(void); extern_pfx void file8_function4(void); extern_pfx void file8_function5(void); extern_pfx void file8_function6(void); #undef extern_pfx 7.16 file8.c /* switch statement samples */ #define file8_c /****************************************************************************** include files ******************************************************************************/ #include ocommnlib.ho #include ofile2.ho #include ofile5.ho #include ofile8.ho /* this file has if equivalent of switches in file 5. compare rom in both */ /* look for optimization in first two cases. cases in sequence also. see if switch table used */ void file8_function1(void) { if (global_1 == cbench_case_1) file2_function1(1); else if (global_1 == cbench_case_2) file2_function1(1); else if (global_1 == cbench_case_3) file2_function2(5); else if (global_1 == cbench_case_4) file2_function3(5); else if (global_1 == cbench_case_5)
60/63 performance comparison between st72254 and pic16f876 file2_function4(); else { file2_function4(); } } /* cases out of order. verify how much rom compared to function1 */ void file8_function2(void) { if (global_2 == cbench_case_2) file2_function1(1); else if (global_2 == cbench_case_1) file2_function1(1); else if (global_2 == cbench_case_4) file2_function3(5); else if (global_2 == cbench_case_3) file2_function2(5); else if (global_2 == cbench_case_5) file2_function4(); else { file2_function4(); } } /* several cases. reverse order */ void file8_function3(void) { if (global_7 == cbench_case_12) file2_function1(10); else if (global_7 == cbench_case_11) file2_function1(1); else if (global_7 == cbench_case_10) { file2_function2(3); file2_function1(1); file2_function3(10); } else if (global_7 == cbench_case_9) file2_function2(5); else if (global_7 == cbench_case_8) file2_function3(5); else if (global_7 == cbench_case_5) file2_function4(); else file2_function4(); } /* just two cases here. check if it is more efficient than if */ void file8_function4(void) { if (global_17 == cbench_case_12) file2_function1(10); else { file2_function4(); }
61/63 performance comparison between st72254 and pic16f876 } /* 3 cases. check if it is efficient to use switch or if */ void file8_function5(void) { if (global_19 == cbench_case_1) file2_function1(10); else if (global_19 == cbench_case_2) { if ((global_9) && (global_1 & 0x01)) { file2_function4(); } } else file2_function4(); } /* 12 cases. look for switch efficiency */ void file8_function6(void) { if (global_4 == cbench_case_1) file2_function1(1); else if (global_4 == cbench_case_2) file2_function1(1); else if (global_4 == cbench_case_3) file2_function2(5); else if (global_4 == cbench_case_4) file2_function3(5); else if (global_4 == cbench_case_5) file2_function4(); else if (global_4 == cbench_case_6) file2_function6(); else if (global_4 == cbench_case_7) file2_function7(); else if (global_4 == cbench_case_8) file2_function8(); else if (global_4 == cbench_case_9) file2_function9(); else if (global_4 == cbench_case_10) file2_function10(); else if (global_4 == cbench_case_11) file2_function8(); else if (global_4 == cbench_case_12) file2_function9(); else file2_function10(); } 7.17 file9.c /* switch statement samples */ #define file9_c /****************************************************************************** include files *****************************************************************************/
62/63 performance comparison between st72254 and pic16f876 #include ocommnlib.ho #include ofile2.ho #include ofile5.ho /* signed arithmetic in this file */ signed char local_1; signed char local_2; signed int local_3; signed int local_4; void file9_function1( void ); unsigned int file9_function2( void ); unsigned char file9_function3( unsigned int ref_time, unsigned int desired_interval ); void file9_function1( void ) { local_1 = 55 - 100; local_2 = ( 9 - 24 ) * 2; local_3 = 2000 - 5000; local_4 = ( 3 - 7 ) / 5; } unsigned int file9_function2( void ) { return( local_3 ); /*round down*/ } unsigned char file9_function3( unsigned int ref_time, unsigned int desired_interval ) { if(( unsigned int )( local_3 - ref_time ) >= desired_interval ) return( 1 ); return( 0 ); }
63/63 performance comparison between st72254 and pic16f876 othe present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connexion with their products.o information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publication are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroelectronics. the st logo is a registered trademark of stmicroelectronics ? 1999 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - china - finland - france - germany - hong kong - india - italy - japan - malaysia - malta - morocco - singapore - spain sweden - switzerland - united kingdom - u.s.a. http:// www.st.com


▲Up To Search▲   

 
Price & Availability of AN1151

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X